package com.hdy.net.order.bean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BasicDataResponse extends Response{
    private List<CategoryBean> category;
    private List<DishBean> dishes;
    private List<BaseBean> reasons;
    private List<BaseBean> cooks;
    private Map<String, List> maps;

    public List getCategory() {
        return category;
    }

    public void setCategory(List category) {
        this.category = category;
    }

    public List getDishes() {
        return dishes;
    }

    public void setDishes(List dishes) {
        this.dishes = dishes;
    }

    public List getReasons() {
        return reasons;
    }

    public void setReasons(List reasons) {
        this.reasons = reasons;
    }

    public List getCooks() {
        return cooks;
    }

    public void setCooks(List cooks) {
        this.cooks = cooks;
    }

    public Map<String, List> getMaps() {
        return maps;
    }

    public void setMaps(Map<String, List> maps) {
        this.maps = maps;
    }

    /**
     * 获取到数据后，自我分析成可用数据结构
     */
    public void analyse() {
        if (maps == null) {
            maps = new HashMap<>();
        }

        if (category == null || dishes == null) {
            return;
        }

        if (category.size() > 0 && dishes.size() >0) {
            for (int i = 0; i < category.size(); i ++) {
                CategoryBean bean = category.get(i);
                List<DishBean> dish = new ArrayList<>();
                for (int j = 0; j < dishes.size(); j ++) {
                    if (bean.getCode().equals(dishes.get(j).getCategoryId())) {
                        dish.add(dishes.get(j));
                    }
                }
                maps.put(bean.getCode(), dish);
            }
        }
    }
}
